package api

import (
	"api-gateway/basic/config"
	__ "api-gateway/basic/proto"
	"api-gateway/handler/request"
	"api-gateway/handler/resp"
	"github.com/gin-gonic/gin"
)

func AddRecord(c *gin.Context) {
	var req request.AddRecordReq
	if err := c.ShouldBind(&req); err != nil {
		resp.Error(c, 400, "参数有误", err.Error())
		return
	}

	record, err := config.DoctorClient.AddRecord(c, &__.AddRecordReq{
		ReservationId: req.PatientId,
		PatientId:     req.PatientId,
		CardId:        req.CardId,
		DoctorId:      req.DoctorId,
		Duration:      req.Duration,
	})
	if err != nil {
		resp.Error(c, 500, "服务端错误", err.Error())
		return
	}

	resp.Success(c, "问诊添加成功", record.RecordId)
}
